/*
 * @Autor: Haiting Zhao
 * @Date: 2022-02-26 14:42:26
 * @LastEditors: Haiting Zhao
 * @LastEditTime: 2022-04-04 10:37:27
 * @Description: file content
 * @FilePath: \league_and_student_organization_management_system_font\src\router\index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import crypto from '../crypto/index'

Vue.use(VueRouter)
var mpath = []
for (var i = 1; i < 70; i++) {
  mpath[i] = crypto.set(i)
}

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/login',
    name: 'Login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Login.vue')
  },
  {
    path: '/center',
    name: 'Center',
    redirect: '/' + mpath[2],
    meta: { permission: true },
    // beforeEnter: function (to, from, next) {
    //   if (sessionStorage.getItem('token')) {
    //     next()
    //   } else {
    //     this.$message.info('请先登录')
    //     next('/')
    //   }
    // },
    component: () => import(/* webpackChunkName: "about" */ '../views/Center.vue'),
    children: [
      { path: '/' + mpath[2], name: 'Weeklysummary', component: () => import(/* webpackChunkName: "about" */ '../views/Weeklysummary/index.vue') }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
NProgress.configure({ showSpinner: true })
// 在路由跳转前用NProgress.start()标记下进度条开始
router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})

// 在路由跳转后用NProgress.done()标记下结束
router.afterEach(() => {
  NProgress.done()
})
export default router
